﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Windows.Forms;

namespace LabelPrintSystem
{
    class ClsWebDataForMOD
    {

    }

    class ClsUserForMOD
    {
        //登录与权限验证用 
        /* 深圳  http://10.53.20.170/pa/WebService/ServiceForCommon/MembershipService.asmx
         * 西安  http://10.53.60.6/pa/WebService/ServiceForCommon/MembershipService.asmx
         * 吉安  http://10.53.80.11/pa/WebService/ServiceForCommon/MembershipService.asmx
         
         射频MES系统三地服务器IP：深圳：10.53.20.170
         西安：10.53.60.6
         吉安：10.53.80.11
         西安网段：60－69
         吉安网段：80－89
         深圳网段：其它
       */

        string url = "http://10.53.20.170/pa/WebService/ServiceForCommon/MembershipService.asmx";
        MicroWebHelper m_webObj;

        public ClsUserForMOD()
        {//构造
            m_webObj = new MicroWebHelper();
            string path = "";
            IniFile.SetFileName(Application.StartupPath + "\\Other.ini");
            path = IniFile.IniReadValue("WebPath", "UserForMODPath", "");
            if (path != "" && path != null) url = path;
        }
        public ClsUserForMOD(string ip)
        {//构造
            m_webObj = new MicroWebHelper();
            string segment = ip.Split(new char[1] { '.' })[2];
            string[] XAsegment = new string[] { "60", "61", "62", "63", "64", "65", "66", "67", "68", "69" };
            string[] JAsegment = new string[] { "80", "81", "82", "83", "84", "85", "86", "87", "88", "89" };
            foreach (string str in XAsegment)
            {
                if (str == segment)
                {
                    url = "http://10.53.60.6/pa/WebService/ServiceForCommon/MembershipService.asmx";
                    return;
                }
            }
            foreach (string str in JAsegment)
            {
                if (str == segment)
                {
                    url = "http://10.53.80.11/pa/WebService/ServiceForCommon/MembershipService.asmx";
                    return;
                }
            }
        }

        public bool AuthenticateUser(string Username, string Password)
        {
            //SOAP 1.2

            //以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。

            //POST /pa/WebService/ServiceForCommon/MembershipService.asmx HTTP/1.1
            //Host: 10.53.20.170
            //Content-Type: application/soap+xml; charset=utf-8
            //Content-Length: length

            //<?xml version="1.0" encoding="utf-8"?>
            //<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
            //  <soap12:Header>
            //    <AuthHeaderGB xmlns="http://tempuri.org/">
            //      <Username>string</Username>
            //      <Password>string</Password>
            //    </AuthHeaderGB>
            //  </soap12:Header>
            //  <soap12:Body>
            //    <AuthenticateUser xmlns="http://tempuri.org/" />
            //  </soap12:Body>
            //</soap12:Envelope>

            //HTTP/1.1 200 OK
            //Content-Type: application/soap+xml; charset=utf-8
            //Content-Length: length

            //<?xml version="1.0" encoding="utf-8"?>
            //<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
            //  <soap12:Body>
            //    <AuthenticateUserResponse xmlns="http://tempuri.org/">
            //      <AuthenticateUserResult>boolean</AuthenticateUserResult>
            //    </AuthenticateUserResponse>
            //  </soap12:Body>
            //</soap12:Envelope>

            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("Username", Username);
                pairs.Add("Password", Password);
                // XmlDocument doc1 = m_webObj.QuerySoapWebService(url, "AuthHeaderGB", pairs);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "AuthenticateUser", pairs, "1.2", true);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return Convert.ToBoolean(ret);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>AuthenticateUser");
                return false;
            }
        }
    }
    class ClsCSVersionForMOD
    {
        //客户端软件版本管控用
        /* 深圳  http://10.53.20.170/pa/WebService/ServiceForCommon/ClientSoftware_VersionControl_Service.asmx
         * 西安  http://10.53.60.6/pa/WebService/ServiceForCommon/ClientSoftware_VersionControl_Service.asmx
         * 吉安  http://10.53.80.11/pa/WebService/ServiceForCommon/ClientSoftware_VersionControl_Service.asmx
         
         射频MES系统三地服务器IP：深圳：10.53.20.170
         西安：10.53.60.6
         吉安：10.53.80.11
         西安网段：60－69
         吉安网段：80－89
         深圳网段：其它
       */


        string url = "http://10.53.20.170/pa/WebService/ServiceForCommon/ClientSoftware_VersionControl_Service.asmx";
        MicroWebHelper m_webObj;
        public ClsCSVersionForMOD()
        {//构造
            m_webObj = new MicroWebHelper();
            string path = "";
            IniFile.SetFileName(Application.StartupPath + "\\Other.ini");
            path = IniFile.IniReadValue("WebPath", "CSVersionForMOD", "");
            if (path != "" && path != null) url = path;
        }
        public ClsCSVersionForMOD(string ip)
        {//构造
            m_webObj = new MicroWebHelper();
            string segment = ip.Split(new char[1] { '.' })[2];
            string[] XAsegment = new string[] { "60", "61", "62", "63", "64", "65", "66", "67", "68", "69" };
            string[] JAsegment = new string[] { "80", "81", "82", "83", "84", "85", "86", "87", "88", "89" };
            foreach (string str in XAsegment)
            {
                if (str == segment)
                {
                    url = "http://10.53.60.6/pa/WebService/ServiceForCommon/ClientSoftware_VersionControl_Service.asmx";
                    return;
                }
            }
            foreach (string str in JAsegment)
            {
                if (str == segment)
                {
                    url = "http://10.53.80.11/pa/WebService/ServiceForCommon/ClientSoftware_VersionControl_Service.asmx";
                    return;
                }
            }
        }

        public bool VersionCheck(string csName, string csVersion)
        {
            //SOAP 1.2

            //以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。

            //POST /pa/WebService/ServiceForCommon/ClientSoftware_VersionControl_Service.asmx HTTP/1.1
            //Host: 10.53.20.170
            //Content-Type: application/soap+xml; charset=utf-8
            //Content-Length: length

            //<?xml version="1.0" encoding="utf-8"?>
            //<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
            //  <soap12:Body>
            //    <VersionCheck xmlns="http://tempuri.org/">
            //      <csName>string</csName>
            //      <csVersion>string</csVersion>
            //    </VersionCheck>
            //  </soap12:Body>
            //</soap12:Envelope>

            //HTTP/1.1 200 OK
            //Content-Type: application/soap+xml; charset=utf-8
            //Content-Length: length

            //<?xml version="1.0" encoding="utf-8"?>
            //<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
            //  <soap12:Body>
            //    <VersionCheckResponse xmlns="http://tempuri.org/">
            //      <VersionCheckResult>boolean</VersionCheckResult>
            //    </VersionCheckResponse>
            //  </soap12:Body>
            //</soap12:Envelope>


            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("csName", csName);
                pairs.Add("csVersion", csVersion);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "VersionCheck", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return Convert.ToBoolean(ret);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>VersionCheck");
                return false;
            }
        }
    }
    class ClsResultForMOD
    {
        //NSN包装工位外箱标签打印用
        /* 深圳  http://10.53.20.170/pa/WebService/ServiceForClient/ProductPackage_LabelPrint_forNSN_Service.asmx
         * 西安  http://10.53.60.6/pa/WebService/ServiceForClient/ProductPackage_LabelPrint_forNSN_Service.asmx
         * 吉安  http://10.53.80.11/pa/WebService/ServiceForClient/ProductPackage_LabelPrint_forNSN_Service.asmx
         
         射频MES系统三地服务器IP：深圳：10.53.20.170
         西安：10.53.60.6
         吉安：10.53.80.11
         西安网段：60－69
         吉安网段：80－89
         深圳网段：其它
       */

        string url = "http://10.53.20.170/pa/WebService/ServiceForClient/ProductPackage_LabelPrint_forNSN_Service.asmx";
        MicroWebHelper m_webObj;
        public ClsResultForMOD()
        {//构造
            m_webObj = new MicroWebHelper();
            string path = "";
            IniFile.SetFileName(Application.StartupPath + "\\Other.ini");
            path = IniFile.IniReadValue("WebPath", "ResultForMODPath", "");
            if (path != "" && path != null) url = path;
        }
        public ClsResultForMOD(string ip)
        {//构造
            m_webObj = new MicroWebHelper();
            string segment = ip.Split(new char[1] { '.' })[2];
            string[] XAsegment = new string[] { "60", "61", "62", "63", "64", "65", "66", "67", "68", "69" };
            string[] JAsegment = new string[] { "80", "81", "82", "83", "84", "85", "86", "87", "88", "89" };
            foreach (string str in XAsegment)
            {
                if (str == segment)
                {
                    url = "http://10.53.60.6/pa/WebService/ServiceForClient/ProductPackage_LabelPrint_forNSN_Service.asmx";
                    return;
                }
            }
            foreach (string str in JAsegment)
            {
                if (str == segment)
                {
                    url = "http://10.53.80.11/pa/WebService/ServiceForClient/ProductPackage_LabelPrint_forNSN_Service.asmx";
                    return;
                }
            }
        }

        public bool DataUpload(string packageProductSN, string userID, string pCIP)
        {
            //SOAP 1.2

            //以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。

            //POST /pa/WebService/ServiceForClient/ProductPackage_LabelPrint_forNSN_Service.asmx HTTP/1.1
            //Host: 10.53.20.170
            //Content-Type: application/soap+xml; charset=utf-8
            //Content-Length: length

            //<?xml version="1.0" encoding="utf-8"?>
            //<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
            //  <soap12:Body>
            //    <DataUpload xmlns="http://tempuri.org/">
            //      <packageProductSN>string</packageProductSN>
            //      <userID>string</userID>
            //      <pCIP>string</pCIP>
            //    </DataUpload>
            //  </soap12:Body>
            //</soap12:Envelope>

            //HTTP/1.1 200 OK
            //Content-Type: application/soap+xml; charset=utf-8
            //Content-Length: length

            //<?xml version="1.0" encoding="utf-8"?>
            //<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
            //  <soap12:Body>
            //    <DataUploadResponse xmlns="http://tempuri.org/">
            //      <DataUploadResult>boolean</DataUploadResult>
            //    </DataUploadResponse>
            //  </soap12:Body>
            //</soap12:Envelope>         
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("packageProductSN", packageProductSN);
                pairs.Add("userID", userID);
                pairs.Add("pCIP", pCIP);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "DataUpload", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return Convert.ToBoolean(ret);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>DataUpload");
                return false;
            }
        }

        public bool HasValid_PackageData(string packageProductSN)
        {
            //HasValid_PackageData

            //判断产品是否包装过

            //SOAP 1.2

            //以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。

            //POST /pa/WebService/ServiceForClient/ProductPackage_LabelPrint_forNSN_Service.asmx HTTP/1.1
            //Host: 10.53.20.170
            //Content-Type: application/soap+xml; charset=utf-8
            //Content-Length: length

            //<?xml version="1.0" encoding="utf-8"?>
            //<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
            //  <soap12:Body>
            //    <HasValid_PackageData xmlns="http://tempuri.org/">
            //      <packageProductSN>string</packageProductSN>
            //    </HasValid_PackageData>
            //  </soap12:Body>
            //</soap12:Envelope>

            //HTTP/1.1 200 OK
            //Content-Type: application/soap+xml; charset=utf-8
            //Content-Length: length

            //<?xml version="1.0" encoding="utf-8"?>
            //<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
            //  <soap12:Body>
            //    <HasValid_PackageDataResponse xmlns="http://tempuri.org/">
            //      <HasValid_PackageDataResult>boolean</HasValid_PackageDataResult>
            //    </HasValid_PackageDataResponse>
            //  </soap12:Body>
            //</soap12:Envelope>           
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("packageProductSN", packageProductSN);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "HasValid_PackageData", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return Convert.ToBoolean(ret);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>HasValid_PackageData");
                return false;
            }
        }

        public string GetProductTypeID_byPackageProductSN(string packageProductSN)
        {
            //GetProductTypeID_byPackageProductSN

            //通过成品序列号，获取关联工序中的S代码，在HasValid_PackageData接口返回ture后调用

            //SOAP 1.2

            //以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。

            //POST /pa/WebService/ServiceForClient/ProductPackage_LabelPrint_forNSN_Service.asmx HTTP/1.1
            //Host: 10.53.20.170
            //Content-Type: application/soap+xml; charset=utf-8
            //Content-Length: length

            //<?xml version="1.0" encoding="utf-8"?>
            //<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
            //  <soap12:Body>
            //    <GetProductTypeID_byPackageProductSN xmlns="http://tempuri.org/">
            //      <packageProductSN>string</packageProductSN>
            //    </GetProductTypeID_byPackageProductSN>
            //  </soap12:Body>
            //</soap12:Envelope>

            //HTTP/1.1 200 OK
            //Content-Type: application/soap+xml; charset=utf-8
            //Content-Length: length

            //<?xml version="1.0" encoding="utf-8"?>
            //<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
            //  <soap12:Body>
            //    <GetProductTypeID_byPackageProductSNResponse xmlns="http://tempuri.org/">
            //      <GetProductTypeID_byPackageProductSNResult>string</GetProductTypeID_byPackageProductSNResult>
            //    </GetProductTypeID_byPackageProductSNResponse>
            //  </soap12:Body>
            //</soap12:Envelope>

            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("packageProductSN", packageProductSN);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "GetProductTypeID_byPackageProductSN", pairs);
                if (doc == null) return string.Empty;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return ret;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>GetProductTypeID_byPackageProductSN");
                return string.Empty;
            }
        }
    }

    class ClsServicePIMAndElecForAntenna
    {
        //天线交调电性能接口地址	http://10.53.20.172/ATS/WebService/ServiceForPIMAndElec.asmx
        string url = "http://10.53.20.172/ATS/WebService/ServiceForPIMAndElec.asmx";
        MicroWebHelper m_webObj;
        public ClsServicePIMAndElecForAntenna()
        {//构造
            m_webObj = new MicroWebHelper();
            string path = "";
            IniFile.SetFileName(Application.StartupPath + "\\Other.ini");
            path = IniFile.IniReadValue("WebPath", "PIMAndElecForAntenna", "");
            if (path != "" && path != null) url = path;
        }

        public bool EleResult_AllStatus_GetbySN(string ProductSN)
        {//select [status] from tb_AllStatus where ProductSN='ProductSN' order by [Time] desc
            return true;
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("ProductSN", ProductSN);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "EleResult_GetbySN", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return ret.ToUpper().Contains("PASS");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>ElectricResult_GetbySN");
                return false;
            }
        }

        public bool ElectricResult_GetbySN(string ProductSN)
        {//通过SN，获取SN对应电性能最近时间成品OR成品返修测试结果 
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("ProductSN", ProductSN);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "ElectricResult_GetbySN", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return ret.ToUpper().Contains("PASS");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>ElectricResult_GetbySN");
                return false;
            }
        }

        public ClsDataSpecial PIMSpecail_GetbyMOID(string MOID)
        {//通过MOID，获取MOID对应交调特采数据集合           
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("MOID", MOID);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "PIMSpecail_GetbyMOID", pairs);
                if (doc == null) return null;
                string sXml = doc.GetElementsByTagName("result")[0].InnerText;
                ClsDataSpecial ret;
                if (sXml == null || sXml == "")
                {//未发现特采，初始化无效特采
                    ret = null;
                }
                else
                {
                    ret = (ClsDataSpecial)XmlUtil.XmlTo(sXml, typeof(ClsDataSpecial));
                }
                return ret;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>PIMSpecail_GetbyMOID");
                return null;
            }
        }

        public PIMTestInfo PimResult_GetbySN(string ProductSN)
        {//通过SN，获取SN对应交调最近时间成品OR成品返修测试结果及交调测试最差值           
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("ProductSN", ProductSN);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "PimResult_GetbySN", pairs);
                if (doc == null) return null;
                string sXml = doc.GetElementsByTagName("result")[0].InnerXml;
                sXml = sXml.Replace(@"xmlns=""http://tempuri.org/""", "");
                PIMTestInfo ret;
                if (sXml == null || sXml == "")
                {
                    ret = null;
                }
                else
                {
                    ret = (PIMTestInfo)XmlUtil.XmlTo(sXml, typeof(PIMTestInfo));
                }
                return ret;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>PimResult_GetbySN");
                return null;
            }
        }

        public string ProductMOID_GetbySN(string ProductSN)
        {//通过SN，获取SN对应的批号MOID           
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("ProductSN", ProductSN);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "ProductMOID_GetbySN", pairs);
                if (doc == null) return null; ;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return ret;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>ProductMOID_GetbySN");
                return null;
            }
        }

        public string ProductTypeID_GetbyMOID(string MOID)
        {//通过MOID，获取MOID对应的产品代码(S代码)           
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("MOID", MOID);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "ProductTypeID_GetbyMOID", pairs);
                if (doc == null) return null; ;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return ret;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>ProductTypeID_GetbyMOID");
                return null;
            }
        }

        public string ProductTypeName_GetbyProductTypeID(string ProductTypeID)
        {//通过S代码，获取S代码对应的产品类型名称
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("ProductTypeID", ProductTypeID);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "ProductTypeName_GetbyProductTypeID", pairs);
                if (doc == null) return null;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return ret;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>ProductTypeName_GetbyProductTypeID");
                return null;
            }
        }

        public bool RcuResult_GetbySN(string ProductSN)
        {//通过SN，获取SN对应RCU检测结果
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("ProductSN", ProductSN);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "RcuResult_GetbySN", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return ret.ToUpper().Contains("PASS");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>RcuResult_GetbySN");
                return false;
            }
        }

        public bool AuthenticateUser(string UserID, string Pwd)
        { //用户登录账号验证           
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("UserID", UserID);
                pairs.Add("Pwd", Pwd);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "AuthenticateUser", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return Convert.ToBoolean(ret);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>AuthenticateUser");
                return false;
            }
        }

        public string AuthenticateUser_ForPrintReform(string UserID)
        { //获取用户权限
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("UserID", UserID);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "AuthenticateUser_ForPrintReform", pairs);
                if (doc == null) return null;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return ret;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>AuthenticateUser_ForPrintReform");
                return null;
            }
        }

        public PrintRecordInfo[] Atenna_PrintData_Download(string ProductSN)
        { //通过ProductSN,下载SN对应打印记录集合          
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("ProductSN", ProductSN);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "Atenna_PrintData_Download", pairs);
                if (doc == null) return null;
                string sXml = doc.GetElementsByTagName("result")[0].InnerXml;
                if (sXml == "") return null;
                sXml = sXml.Replace(@"xmlns=""http://tempuri.org/""", "");
                sXml = sXml.Insert(0, "<ArrayOfPrintRecordInfo>");
                sXml = sXml.Insert(sXml.Length, "</ArrayOfPrintRecordInfo>");
                PrintRecordInfo[] ret;
                if (sXml == null || sXml == "")
                {//未发现特采，初始化无效特采
                    ret = null;
                }
                else
                {
                    ret = (PrintRecordInfo[])XmlUtil.XmlTo(sXml, typeof(PrintRecordInfo[]));
                }
                return ret;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>Atenna_PrintData_Download");
                return null;
            }
        }

        public bool Atenna_PrintData_Upload(PrintRecordInfo record)
        { //上传打印记录           
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("pi", record);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "Atenna_PrintData_Upload", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return Convert.ToBoolean(ret);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>Atenna_PrintData_Upload");
                return false;
            }
        }
    }

    class ClsServiceForPackage
    {
        //天线包装	http://10.53.20.172/ATS/WebService/ServiceForPackage.asmx
        string url = "http://10.53.20.172/ATS/WebService/ServiceForPackage.asmx";
        MicroWebHelper m_webObj;
        public ClsServiceForPackage()
        {
            m_webObj = new MicroWebHelper();
            string path = "";
            IniFile.SetFileName(Application.StartupPath + "\\Other.ini");
            path = IniFile.IniReadValue("WebPath", "ServiceForPackage", "");
            if (path != "" && path != null) url = path;
        }
        public List<ClsTProductTypeInfo> getProductTypeList()
        {
            try
            {
                Hashtable pairs = new Hashtable();
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "ProductTypeList", pairs);
                if (doc == null) return null;
                string sXml = doc.GetElementsByTagName("result")[0].InnerXml;
                List<ClsTProductTypeInfo> ret = null;
                if (sXml == null || sXml == "")
                {//未发现特采，初始化无效特采
                    ret = null;
                }
                else
                {
                    sXml = sXml.Replace(@"xmlns=""http://tempuri.org/""", "");
                    sXml = sXml.Replace("TProductTypeInfo", "ClsTProductTypeInfo");
                    sXml = sXml.Insert(0, "<ArrayOfClsTProductTypeInfo>");
                    sXml = sXml.Insert(sXml.Length, "</ArrayOfClsTProductTypeInfo>");
                    ClsTProductTypeInfo[] arry = (ClsTProductTypeInfo[])XmlUtil.XmlTo(sXml, typeof(ClsTProductTypeInfo[]));
                    ret = new List<ClsTProductTypeInfo>(arry);
                    ret = (List<ClsTProductTypeInfo>)XmlUtil.XmlToDeserialize(sXml, typeof(List<ClsTProductTypeInfo>));
                }
                return ret;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>ProductTypeList");
                return null;
            }
        }
        public bool IsASN(string antennaSN)
        {
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("antennaSN", antennaSN);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "IsASN", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return Convert.ToBoolean(ret);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>IsASN");
                return false;
            }
        }
        public bool IsRASN(string retrospectSN)
        {
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("retrospectSN", retrospectSN);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "IsRASN", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return Convert.ToBoolean(ret);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>IsRASN");
                return false;
            }
        }
        public bool IsRelevance(string SN)
        {
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("SN", SN);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "IsRelevance", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return Convert.ToBoolean(ret);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>IsRelevance");
                return false;
            }
        }
        public bool UploalPackageData(ClsPackInfo record)
        {
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("tp", record);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "UploalPackageData", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return Convert.ToBoolean(ret);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>UploalPackageData");
                return false;
            }
        }
        public bool UploalRelevanceData(ClsRelevanceInfo record)
        {
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("tr", record);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "UploalRelevanceData", pairs);
                if (doc == null) return false;
                string ret = doc.GetElementsByTagName("result")[0].InnerText;
                return Convert.ToBoolean(ret);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>UploalRelevanceData");
                return false;
            }
        }
        public List<ClsPackConfigInfo> getPackConfigList(string productTypeID)
        {
            try
            {
                Hashtable pairs = new Hashtable();
                pairs.Add("productTypeID", productTypeID);
                XmlDocument doc = m_webObj.QuerySoapWebService(url, "GetTPackConfigInfo_byTPID", pairs);
                if (doc == null) return null;
                string sXml = doc.GetElementsByTagName("result")[0].InnerXml;
                List<ClsPackConfigInfo> ret = null;
                if (sXml == null || sXml == "")
                {
                    ret = null;
                }
                else
                {
                    sXml = sXml.Replace(@"xmlns=""http://tempuri.org/""", "");
                    sXml = sXml.Replace("TPackConfigInfo", "ClsPackConfigInfo");
                    sXml = sXml.Insert(0, "<ArrayOfClsPackConfigInfo>");
                    sXml = sXml.Insert(sXml.Length, "</ArrayOfClsPackConfigInfo>");
                    //ClsPackConfigInfo[] arry = (ClsPackConfigInfo[])XmlUtil.XmlTo(sXml, typeof(ClsPackConfigInfo[]));
                    //ret = new List<ClsPackConfigInfo>(arry);
                    ret = (List<ClsPackConfigInfo>)XmlUtil.XmlToDeserialize(sXml, typeof(List<ClsPackConfigInfo>));
                }
                return ret;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Source + ex.Message + "==>getPackConfigList");
                return null;
            }
        }

    }

}
